// components/patrol/patrol.js
import tool from '../../modules/tool'
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    data: {
      type: Object,
      default: {}
    },
    backgroundColor: {
      type: String,
      default: 'white'
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    handleCardLongPress() {
      if (tool.isLogined() == false) return
      wx.showActionSheet({
        itemList: [`查看${this.properties.data.userData.username}新建的巡查`, `查看属于${this.properties.data.campusInfo.name}-${this.properties.data.categoryInfo.name_simple}的巡查`,
        `查看处于${this.properties.data.status_read}状态的巡查`,
        `查看新建于${this.properties.data.topTitle_hide}的巡查`
        ],
        success: (e) => {
          e = e.tapIndex
          if (e === 0) {
            tool.page.searchPatrol({
              patrolAccount: this.properties.data.userData.account
            })
          }
          if (e === 1) {
            tool.page.searchPatrol({
              campusId: this.properties.data.campusInfo.id,
              categoryId: this.properties.data.categoryInfo.id
            })
          }
          if (e === 2) {
            tool.page.searchPatrol({
              status: this.properties.data.status
            })
          }
          if (e === 3) {
            tool.page.searchPatrol(tool.getDayStartEnd(new Date(this.properties.data.createdAt)))
          }
        }
      })
    },
    handleMoreClick() {
      tool.handleShowPatrolMoreList(this.properties.data)
      return
      this.triggerEvent('more', this.properties.data)
    },
    handleCardClick() {

      tool.page.patrol.info(this.properties.data.id)
      return
      this.triggerEvent('open', this.properties.data)
    }
  },

  attached() {
    console.log(this.properties.backgroundColor)
  }
})